<template>
  <div class="radioCategory">
    <div class="main">
      <div
        class="main_item"
        v-for="item in categories"
        :key="item.id"
        @click="toRadioCategoryPage(item.id)"
      >
        <span
          :style="{
            backgroundImage: 'url(' + item.picWebUrl + ')',
          }"
        >
        </span>
        <p>{{ item.name }}</p>
      </div>
    </div>
  </div>
</template>

<script>
import { getRadioCategory } from "../../../../../api/radioApi";
export default {
  name: "radioCategory",
  components: {},
  data() {
    return {
      categories: [], // 电台分类的数据
    };
  },
  created() {
    this.getRadioCategory();
  },
  methods: {
    // 获取所有的分类
    async getRadioCategory() {
      try {
        let result = await getRadioCategory();
        if (result.code === 200) {
          this.categories = result.categories;
        }
      } catch (error) {}
    },
    toRadioCategoryPage(id) {
      this.$router.push(`/radio/category/${id}`);
    },
  },
  computed: {},
};
</script>

<style lang="less" scoped>
.radioCategory {
  padding: 30px 0;
  .main {
    // background-color: #f5f5f5;
    display: flex;
    flex-wrap: wrap;
    .main_item {
      display: flex;
      width: 200px;
      height: 80px;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      margin-bottom: 20px;
      cursor: pointer;
      &:hover {
        background-color: #f6f7f7;
      }
      span {
        width: 48px;
        height: 48px;
        background-repeat: no-repeat;
        background-position: 0 0;
      }
      p {
        &:hover {
          color: @globalColor;
        }
      }
    }
  }
}
</style>
